package icdecs.connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Class using connect to postgresql Database
 * 
 * @author ThanhNguyen
 * 
 */
public class ConnectDatabase {

	public static final String URI = "jdbc:postgresql://localhost:5432/icdecs_client";
	public static final String USER = "icdecs";
	public static final String PASSWORD = "icdecs";

	public static Connection getConnection() throws SQLException {
		Connection con = null;
		try {

			Class.forName("org.postgresql.Driver");

		} catch (ClassNotFoundException e) {

			System.out.println("Where is your PostgreSQL JDBC Driver? "
					+ "Include in your library path!");
			e.printStackTrace();
			return null;

		}

		System.out.println("PostgreSQL JDBC Driver Registered!");
		con = DriverManager.getConnection(URI, USER, PASSWORD);

		return con;
	}
}
